#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
    int n;
    scanf("%d", &n);
    int arr[101][101];
    int i = 1, j = 1, pos = 1;
    arr[i][j] = 1;
    for (int k = 2; k <= n * n; k++)
    {
        if (pos == 1 && i == 1 && j < n)
        {
            arr[i][++j] = k;
            pos = -1;
        }
        else if (pos == -1 && j == 1 && i < n)
        {
            arr[++i][j] = k;
            pos = 1;
        }
        else if (pos == -1 && i == n && j < n)
        {
            arr[i][++j] = k;
            pos = 1;
        }
        else if (pos == 1 && j == n && i < n)
        {
            arr[++i][j] = k;
            pos = -1;
        }
        else if (pos == 1)
        {
            arr[--i][++j] = k;
        }
        else if (pos == -1)
        {
            arr[++i][--j] = k;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            printf("%d ", arr[i][j]);
        }
        printf("\n");
    }
    return 0;
}